package pattern.singleton;

/**
 * 单例、多例模式
 */
public class SingletonDemo {

    public static void main(String[] args) {
        Singleton beLazySyncInstance1 = Singleton.getBeLazySyncInstance();
        Singleton beLazySyncInstance2 = Singleton.getBeLazySyncInstance();
        Singleton enumInstance1 = Singleton.getEnumInstance();
        Singleton enumInstance2 = Singleton.getEnumInstance();
        System.out.println(beLazySyncInstance1.hashCode());
        System.out.println(beLazySyncInstance2.hashCode());
        System.out.println(enumInstance1.hashCode());
        System.out.println(enumInstance2.hashCode());

        System.out.println(beLazySyncInstance1 == enumInstance1);
        System.out.println(beLazySyncInstance2 == enumInstance2);
        System.out.println(beLazySyncInstance1 == beLazySyncInstance2);
        System.out.println(enumInstance1 == enumInstance2);
        System.out.println(SingletonEnum.INSTANCE.whateverMethod());
    }

}
